const userService=require('../service/user')
//新增
const addUserController=async(ctx,next)=>{
    let results=await userService.addUserService(ctx.request.body)
    if (results) {
        ctx.body={
            code:200,
            msg:'data write success'
        }
    }else {
        ctx.body={
            code:400,
            msg:'params error'
        }
    }
}
//删除
const deleteUserController=async(ctx,next)=>{
    let results=await userService.deleteUserService(ctx.parmas.id)
    if (results) {
        ctx.body={
            code:200,
            msg:'data write success'
        }
    }else {
        ctx.body={
            code:403,
            msg:'params error'
        }
    }
}
//修改
const putUserController=async (ctx,next)=>{
    let results=await userService.putUserController(ctx.request.body)
    if (results&&result.length) {
        ctx.body={
            code:200,
            msg:'修改成功'
        }
    }else {
        ctx.body={
            code:403,
            msg:'修改失败'
        }
    }
}
//查询
const selectUserController=async (ctx,next)=>{
    let results=await userService.selectUserController(ctx.request.body)
    if (results&&result.length) {
        ctx.body={
            code:200,
            msg:'查询成功'
        }
    }else {
        ctx.body={
            code:403,
            msg:'查询失败'
        }
    }
}

//导出
module.exports={
    addUserController,
    deleteUserController,
    putUserController,
    selectUserController
}
